package com.atguigu.gulimall.order.controller;

import com.atguigu.gulimall.order.vo.User;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class RabbitCtroller {

    @Autowired
    RabbitTemplate rabbitTemplate;

    @GetMapping("/test")
    public String test(){
        User user = new User();
        user.setName("zhangsan");
        for (int i = 0; i < 10; i++) {
            user.setAge(i);
            //发送消息
            rabbitTemplate.convertAndSend("order-event-exchange", "order.release.#", user);
        }
        return "haha";
    }
}
